<template>
	<view>
		<view class="status_bar"><view class="top_view"></view></view>
		<view class="ptb20 plr10 flex between alcenter ltcBg">
			<view class="tl">昨日收益</text>
				<view class="pt10 bold ft26">{{dog.yesterday_reward}}</view>
			</view>
			<image src="../../static/image/zuan.png" style="width: 250upx;" mode="widthFix"></image>
		</view>
		<view class="plr10 mt10">
			<view class="ptb10 ft14 bold">我的智能狗</view>
			<view class="bgliner ptb15 pl15 flex radius2" v-if="have">
				<image v-if="dog.financial_product" :src="$domain+dog.financial_product.sjwnb" class="wt50 h50 radius50p" mode=""></image>
				<view class="white flex1 pl15">
					<view class="flex alcenter between">
						<text class="ft16" v-if="dog.financial_product">{{dog.financial_product.name}}</text>
						<navigator url="dog" class="flex alcenter ptb5 pl15 pr5 ral20" style="background-color: #f9bb57;">
							<text class="pr5">智能狗升级</text> 
							<image src="../../static/image/up.png" class="wt8" mode="widthFix"></image>
						</navigator>
					</view>
					<view class="pt5">累计收益 {{dog.grand_total_reward}}</view>
					<view class="pt5" v-if="dog.financial_product">奖励比例 {{dog.financial_product.rate_of_reward *100}} %</view>
				</view>
			</view>
			<view class="bgDog flex alcenter ptb15 pl15 flex radius2 h80" v-else>
				<navigator url="dog" class="radius20 ptb5 plr20 ml20 flex alcenter" style="background-color: #f9bb57;">
					<text>立即购买</text>
					<image src="../../static/image/dog.png" class="wt20 h20 ml5" mode=""></image>
				</navigator>
			</view>
			<view class="mt10">
				<view class="ptb10 ft14 bold">收益记录</view>
				<view class="ptb10 bdb_1e" v-for="(item,index) in list" :key="item.id">
					<view class="flex between">
						<text class="ft14 bold redColor">+{{item.value}}</text>
						<text class="gray4">{{item.created_at.substring(10,16)}} {{item.created_at.substring(5,7)}}/{{item.created_at.substring(8,11)}}</text>
					</view>
					<view class="pt5">{{item.memo}}</view>
				</view>
				<view class="tc pt30 pb100" v-if='list.length==0'>
					<image src="/static/image/nodata.png" class="w50 h120"></image>
					<view class="gray7">{{$t('home.norecord')}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dog:{},
				list:[],
				page:1,
				hasMore:true,
				have:true
			}
		},
		onShow() {
			this.getDog();
			this.getList();
		},
		methods: {
			
			getDog(){
				this.$utils.initDataToken({ url: 'added/current_account', data: {}, type: 'get' }, (res, msg) => {
					uni.stopPullDownRefresh();
	                this.dog = res;
					this.have = res.financial_product==null ? false :true;
				});
			},
			getList(){
				let that = this;
				that.$utils.noshowToken({ url: 'added/reward_record',data:{page:that.page,limit:30}}, res => {
					var data = res;
					that.list = data;
					// uni.stopPullDownRefresh();
					// that.list = (that.page == 1) ? data : that.list.concat(data);
					// that.hasMore = (res.last_page == res.current_page) ? false : true;
				});
			}
		}
	}
</script>

<style>
.ltcBg{
	background: url(../../static/image/ltc.png) no-repeat;
	background-size: 100% 100%;
}
.bgDog{
	background: url(../../static/image/dogbg.png) no-repeat;
	background-size: 100% 100%;
	background-position: center;
}
</style>
